package com.hs.server.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hs.server.domain.ShResourcexx;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
public interface ShResourcexxMapper extends BaseMapper<ShResourcexx> {
    @Select("SELECT * FROM sh_resourcexx WHERE fwqbh = #{fwqbh}")
    ShResourcexx getResourcexx(int fwqbh);

    @Select("SELECT * FROM sh_resourcexx WHERE sfkx = '1' AND zt = '1' ORDER BY RAND() limit 1")
    ShResourcexx getOneLeisureResourcexx();

    //可用资源数量
    @Select("SELECT COUNT(*) FROM sh_resourcexx WHERE zt = '1'")
    int getResourceNum();

    //繁忙资源数量
    @Select("SELECT COUNT(*) FROM sh_resourcexx WHERE sfkx = '0' AND zt = '1'")
    int getBusyingResourceNum();

    //空闲资源数量
    @Select("SELECT COUNT(*) FROM sh_resourcexx WHERE sfkx = '1' AND zt = '1'")
    int getLeisureResourceNum();

    @Select("SELECT shzcs FROM sh_resourcexx WHERE fwqbh = #{fwqbh}")
    int getShzcs(String fwqbh);

    @Select("SELECT clcs FROM sh_resourcexx WHERE fwqbh = #{fwqbh}")
    int getclcs(String fwqbh);

    @Update("UPDATE sh_resourcexx SET sfkx='1' WHERE zt = '1'")
    int updateSfkx();

    @Update("UPDATE sh_resourcexx SET zt = '1',sfkx='1' where zt = '0';")
    int resetResource();

}
